#'
#' get a population from the whole community
#' 
#' @aliases get_population get_populations
#'
#' @usage
#' get_population(com,spname)
#' get_populations(com,spnames)
#'
#' @param com a community object
#' @param spname a name of the interested species
#' @param spnames a vector of the interested species
#'
#' @return
#' get_population returns a population object
#' get_populations returns a community object
#'
#' @examples
#' set.seed(1)
#' 
#' com=rcommunity()
#' sp2=get_population(com,"sp2")
#' 
#' 
#' @export
get_population=function(com,spname){
  seli=com$species==spname
  pop=com[seli,]
  
  pop=as.population(pop)
  
  return(pop)
}

#' @export
get_populations=function(com,spnames){
  seli=rep(FALSE,total_abundance(com))
  for(i in 1:length(spnames)){
    seli=seli | com$species==spnames[i]
  }
  return(com[seli,])
}